import { CoreAliSmsTemplate } from './ali-sms-template.entity'
import { Entity, PrimaryGeneratedColumn, Column, OneToMany, ManyToOne } from 'typeorm'
import { CoreAliSmsSign } from './ali-sms-sign.entity'
import { Account } from '../../../entities'
/**
 * 短信服务 dysms.console.aliyun.com
 */
@Entity()
export class CoreAli {
  @PrimaryGeneratedColumn()
  id: number

  @Column({
    comment: '名称'
  })
  name: string

  // ItYV5FaAYY7PXvXn
  @Column({
    comment: 'AccessKey ID'
  })
  accessKeyID: string
  // D6FGgyuusmOIAUh6PPpfSq24HEX5ds
  @Column({
    comment: 'Access Key Secret'
  })
  accessKeySecret: string

  // 签名配置
  @OneToMany(type => CoreAliSmsSign, smsSign => smsSign.ali, {
    lazy: true
  })
  signs: CoreAliSmsSign[]
  // 模板配置
  @OneToMany(type => CoreAliSmsTemplate, smsSign => smsSign.ali, {
    lazy: true
  })
  templates: CoreAliSmsTemplate[]

  @ManyToOne(type => Account, account => account.alis)
  account: Account
}
